package com.sean.framework.util;

import java.io.File;
import java.io.IOException;

import android.util.Log;

public class CacheUtil {
	private String dirPath;
	
	public CacheUtil(String dirPath){
		this.dirPath = dirPath;
	}
	
	public String getWeatherDataCachePath(){
		String path = this.dirPath + "/weather_data.dat";
		this.createFile(path);
		Log.d("cache", path);
		return path;
	}
	
	public String getQueryLocationCachePath(){
		String path = this.dirPath + "/query_location.dat";
		this.createFile(path);
		Log.d("cache", path);
		return path;
	}
	
	public String getOutlineListCachePath(){
		String path = this.dirPath + "/get_ontline_list.dat";
		this.createFile(path);
		Log.d("cache", path);
		return path;
	}
	
	public String getReportCachePath(){
		String path = this.dirPath + "/get_report_list.dat";
		this.createFile(path);
		Log.d("cache", path);
		return path;
	}
	
	public String getOutlineListByLocationCachePath(){
		String path = this.dirPath + "/get_ontline_list_by_location.dat";
		this.createFile(path);
		Log.d("cache", path);
		return path;
	}
	
	public String getRadioLoginCachePath(){
		String path = this.dirPath + "/get_radio_login.dat";
		this.createFile(path);
		Log.d("cache", path);
		return path;
	}
	
	public String getRadioCreateAccountCachePath(){
		String path = this.dirPath + "/get_radio_create_account.dat";
		this.createFile(path);
		Log.d("cache", path);
		return path;
	}
	
	
	public String getCountryListCachePath(){
		String path = this.dirPath + "/get_country_list.dat";
		this.createFile(path);
		Log.d("cache", path);
		return path;
	}
	
	public String getRadioLinksCachePath(){
		String path = this.dirPath + "/tune.ashx";
		this.createFile(path);
		Log.d("cache", path);
		return path;
	}
	
	private File createFile(String path){
		File file = new File(path);
		if(!file.exists()){
			file.getParentFile().mkdirs();
		}
		File nomediaFile = new File(file.getParent() , ".nomedia");
		Log.d("cache", "nomediaFile >>>  " +  nomediaFile.getPath());
		if(!nomediaFile.exists()){
			try {
				nomediaFile.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		//file.deleteOnExit();
		return file;
	}
}
